﻿@model Transport.Areas.Administrator.Models.RegionModel
@using (Html.BeginForm("Save", "Region", FormMethod.Post))
{
    <div class="section-header">
        <div class="title">
            <img src="@Url.Content("~/Areas/Administrator/Content/images/ico-catalog.png")" alt="" />
            @(Model.RegionId > 0 ? "Sửa vùng miền" : "Tạo mới vùng miền")
        </div>
        <div class="options">
            <button type="submit" name="save" value="Save" tabindex="6" class="t-button">Lưu</button>
            <a href="@Url.Action("index")" tabindex="8" class="t-button">Quay về</a>
        </div>
    </div>
    
    @Html.HiddenFor(model => model.RegionId)
    <table width="99%">
        <tr>
            <td width="100" class="adminTitle">
                @Html.Label("Tên Thùng")
                <span class="field_required">*</span>
            </td>
            <td class="adminData">
                @Html.TextBoxFor(model => model.RegionName)
                @Html.ValidationMessageFor(model => model.RegionName)
            </td>
        </tr>
    </table>
}
@if (Model.RegionId > 0)
{
@Html.Osd().HiddenPopupWindow("Cảnh Báo", Helpers.DeleteConfirmMessageBox("Bạn có thực sự muốn xóa không", @Url.Action("DeleteStateProvinceBelongToRegion", "Region", new { area = "administrator" })).ToHtmlString())
<div class="section-header">
    <div class="title">
        <img alt="" src="@Url.Content("~/Areas/Administrator/Content/images/ico-catalog.png")">
        Danh sách các tỉnh thành:
    </div>
    
    <div class="options">
        <a href="@Url.Action("CreateStateProvinceBelongToRegion", "Region", new { regionId = Model.RegionId })" tabindex="8" class="t-button">Tạo mới tỉnh thành</a>
    </div>
</div>
@(Html.Telerik().Grid<Transport.Areas.Administrator.Models.StateProvinceBelongToRegionModel>()
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(x => x.StateProvinceBelongToRegionId).Title("MS")
                        .Width(100)
                        .Filterable(false);
        columns.Bound(x => x.StateProvinceCode).Title("Mã")
            .Width(150)
            .Filterable(false);
        columns.Bound(x => x.StateProvinceName).Title("Tên Tỉnh Thành")
            .Filterable(false);
        columns.Bound(p => p.StateProvinceBelongToRegionId)
            .ClientTemplate("<a onclick='onMessageBoxActionDelete(<#= StateProvinceBelongToRegionId #>)'><img src=\"" + Url.Content("~/Content/Images/delete_16_16.png") + "\" /></a>")
            .HtmlAttributes(new { style = "text-align:center" })
            .Title(string.Empty)
            .Width(100).Sortable(false)
            .Filterable(false);
    })
    .DataBinding(dataBinding => dataBinding.Ajax().Select("GetStateProvinceBelongToRegions", "Region", new { regionId = Model.RegionId }))
    .Pageable()
    .Sortable()
    .Scrollable(scrolling => scrolling.Height(300))
    .Groupable(grouping => grouping.Enabled(false))
    .Filterable()
) 
}